package com.matt.repository;

import com.matt.domain.Product;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import java.util.List;
import java.util.Set;

/**
 * *****************
 * Created by Ron
 * from com.matt
 * on 2018/6/13 0013.
 *********************
 */

public interface ProductRepository extends JpaRepository<Product, String>, JpaSpecificationExecutor<Product> {

//    List<Product> findByAreaIdAndDeletedIsFalseAndIsVisible(String areaId, Integer isVisible);
//
//    Page<Product> findAllByDeletedIsFalseAndIsVisibleIsTrueOrderByCreatedDesc(Pageable pageable);
//
//    List<Product> findByAreaIdAndDeletedIsFalseOrderByCreatedDesc(String areaId);

    Product findFirstByAreaId(String areaId);
    List<Product> findAllByAreaIdAndIdInAndIsVisible(String areaId, List<String> ids, Integer isVisible);

    Product findByNameAndAreaIdAndIdNotAndDeletedIsFalse(String name, String areaId, String id);

    Product findByNameAndAreaIdAndDeletedIsFalse(String name,String areaId);

    Product findByIdAndAreaIdAndDeletedIsFalse(String id, String areaId);

    Product findByIdAndAreaId(String id, String areaId);

    Product findByIdAndDeletedIsFalse(String id);

    List<Product> findAllByAreaIdAndIsVisibleAndInitiableIsTrue(String areaId, Integer isVisible);
    List<Product> findAllByAreaIdAndIsVisibleAndNameLikeAndInitiableIsTrue(String areaId, String name, Integer isVisible);
    List<Product> findAllByAreaIdAndIdInAndIsVisibleOrderByCreatedDesc(String areaId, List<String> ids, Integer isVisible);

}
